package com.yueka.controller;

import com.yueka.pojo.R;
import com.yueka.pojo.entity.experience.Experience;
import com.yueka.service.ExperienceService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RequestMapping("/experience")
@RestController
public class ExperienceController {

    @Autowired
    private ExperienceService experienceService;

    @GetMapping("/list")
    public R list() {
        try {
            return R.success(experienceService.list());
        } catch (Exception e) {
            return R.error(e.getMessage());
        }
    }

    @PostMapping("/insert")
    public R insert(@RequestBody Experience experience) {
        try {
            experienceService.insert(experience);
            return R.success();
        } catch (Exception e) {
            return R.error(e.getMessage());
        }
    }

    @PostMapping("/update")
    public R update(@RequestBody Experience experience) {
        try {
            experienceService.update(experience);
            return R.success();
        } catch (Exception e) {
            return R.error(e.getMessage());
        }
    }

    @GetMapping("/delete")
    public R delete(Integer id) {
        try {
            experienceService.delete(id);
            return R.success();
        } catch (Exception e) {
            return R.error(e.getMessage());
        }
    }


}
